// tests.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include <cppunit/CompilerOutputter.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/ui/text/TestRunner.h>
#include <cppunit/TestResult.h>
#include <cppunit/TestResultCollector.h>
#include <cppunit/XmlOutputter.h>
#include <ostream>

int _tmain(int argc, _TCHAR* argv[])
{
	// Get the top level suite from the registry
	CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();

	CppUnit::TestResult    controller;
	CppUnit::TestResultCollector result;
	controller.addListener(&result);

	// Adds the test to the list of test to run
	CppUnit::TextUi::TestRunner runner;
	runner.addTest( suite );
	runner.run(controller);

	std::ofstream xmlFileOut("cpptestresults.xml");
	CppUnit::XmlOutputter xmlOut(&result, xmlFileOut);
	xmlOut.write();

	// Return error code 1 if the one of test failed.
	return result.wasSuccessful() ? 0 : 1;
}

